import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { getBanner } from '../http/request';
import store from '@/store';
export const fetchBanner = createAsyncThunk(
    'recommend/banners',
    async (args, thunkAPI) => {
        const response = await getBanner();

        thunkAPI.dispatch(getBannerAction(response.data));
    },
);
const recommendStore = createSlice({
    name: 'recommend',
    initialState: {
        banners: [],
    },
    reducers: {
        getBannerAction(state, { payload }) {
            console.log('得到', payload);

            state.banners = payload.banners;
        },
    },
});
export const { getBannerAction } = recommendStore.actions;
export default recommendStore.reducer;
